package model.person;

import java.util.ArrayList;
import java.util.List;

public class PersonManagement {

	private List<Person> persons = new ArrayList<Person>();

	public PersonManagement() {
	}

	public void addEmployee(String firstName, String lastName, int salary,
			Function[] functions) {
		persons.add(PersonFactory.createEmployee(firstName, lastName, salary,
				functions));
	}

	public void addMember(String firstName, String lastName) {
		persons.add(PersonFactory.createMember(firstName, lastName));

	}

	public Person getPersonByFullName(String fullName) {
		String firstName = fullName.split(" ")[0];
		String lastName = fullName.split(" ")[1];
		return getPerson(firstName, lastName);
	}

	public Person getPerson(String firstName, String lastName) {
		for (Person p : persons) {
			if (p.getFirstName().equals(firstName)
					&& p.getLastname().equals(lastName)) {
				return p;
			}
		}
		return null;
	}

}
